python bfs tree